var vm_table = new Vue({
        el: "#vm_table",
        data: {
            pageInfo: new Object(),
            column: [["id", "id", "onlyRead"],
                ["学生姓名", "username", "onlyRead"],
                ["性别", "gender", "onlyRead"],
                ["资源级别", "resourcelevel", "onlyRead"],
                ["状态", "rstate", "onlyRead"],
                ["设置班级", "classid", "select"],
                ["设置入学时间", "begintime", "date"],
                ["设置就业时间", "jobtime", "date"]],
            allClass: new Object(),
            checkBox: [],
            checked: false, // 全选款框子
            flag: 0 // 异步请求完成表示
        },
        methods: {
            getAllClass: function () {
                this.$http.get("payStu/allClass").then(function (value) {
                    this.allClass = value.body;
                })
            },
            getAllPayClass: function () {
                this.$http.get("payStu").then(function (value) {
                    this.pageInfo = value.body;
                })
            },
            addClass: function () {
                if (this.checkBox.length == 0)
                    alert("请选择同学。");

                this.flag = this.checkBox.length;
                this.checkBox.forEach(function (value, index) {
                    vm_table.$http.post("payStu/student", vm_table.pageInfo.list[value]).then(function (value) {
                        vm_table.flag--;
                    },function (reason) {
                        alert(reason.body["msg"]);
                    });
                });
            }

        },
        watch: {
            'checked': {
                handler: function (val, oldVal) {
                    if (val) {
                        vm_table.checkBox = [];
                        for (var i = 0; i < vm_table.pageInfo.list.length; i++) {
                            vm_table.checkBox.push(i)
                        }
                    } else {
                        vm_table.checkBox = [];
                    }
                },
                deep: true
            },
            'flag': {
                handler: function (val, oldVal) {
                    if (oldVal > 0 && val == 0) {
                        alert("success.全部插入。");
                        vm_table.getAllPayClass();
                    }
                },
                deep: true
            }
        }
    })
;


// init
vm_table.getAllClass();
vm_table.getAllPayClass();